Nearest Neighbor Demosaicing

Brief Description

File: \examples\Processing\Color\Bayer\NearestNeighbor_maVCL.va

Default Platform: mE5-MA-VCL

Short Description

Nearest Neighbor Bayer Demosaicing

Theory

The nearest neighbor interpolation method is the simplest Bayer demosaicing algorithm. For a Bayer pattern [Bay76] of four neighboring pixels P1 to P4 (see Figure 280, 'Bayer pattern') the missing red (R), green (G) and blue (B) colors can be interpolated according to [Ada95]:

Equation 1.


Here a pattern Red-followed-by-Green is shown, but this interpolation method is equivalent for all Bayer patterns.

Bayer pattern

Figure 280. Bayer pattern


VisualApplets Design

In VisualApplets an example design for nearest neighbor interpolation is implemented. You can find it under \examples\Processing\Color\Bayer\NearestNeighbor_maVCL.va. You can see its basic design structure in Figure 281, 'Basic design structure'. The content of the HierarchicalBoxes InputImage and OutputImage is equivalent to a basic acquisition design (see e.g. 'Basic Acquisition Examples for Camera Link Cameras for marathon, LightBridge and ironman Frame Grabbers').

Basic design structure

Figure 281. Basic design structure


In Figure 282, 'Content of NearestNeighbour' you can see the content of the HierarchicalBox NearestNeighbour. A kernel is defined. The current pixel position is here the upper left corner. The colors red, green and blue are calculated according to Equation 1 in the HierarchicalBoxes Red, Green, Blue and with CurrentPixel using the VisualApplets operator SelectSubkernel. In WhereAmI_Colour the color of the current pixel position in the Bayer pattern is determined using Modulo-,AND-, NOT and NotEqual-operators. The comment boxes in the design give detailed information of the color at the current position and at every link. With three IF operators the missing colors are added to the current pixel. All three colors are merged with the operator MergeComponents.

Content of NearestNeighbour

Figure 282. Content of NearestNeighbour